package com.test.websample.controller;

import com.fasterxml.jackson.databind.json.JsonMapper;
import com.test.websample.pojo.Result;
import com.test.websample.service.UserService;
import com.test.websample.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/books")
public class BooksResourceController {

    JsonMapper mapper = new JsonMapper();

    @Autowired
    UserService userService;

    @GetMapping("/list")
    public Result getBooks(@RequestHeader("Authorization") String token) {
        return Result.success(new ArrayList<Object>(){{
            add("book1");
            add("book2");
            add("book3");
            add(ThreadLocalUtil.get());
        }});
    }
}
